package com.heima.homeservicemanagementsystem.entity.common;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @Description
 * @Author jcf
 * @Date 2025/4/25
 */
@Getter
public enum OrderStatusEnum {
    PendingPayment(0, "待支付"),
    Dispatchinprogress(1, "待服务"),
    Waitingforservice(2, "待评价"),
    inservice(3, "已评价"),
    Ordercompleted(4, "已取消"),
    Cancelled(5, "服务中"),
    CLOSED(6, "已完成"),

    ;
    @EnumValue
    private final Integer value;
    @JsonValue
    private final String desc;

    OrderStatusEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public boolean equals(int status) {
        return this.value == value;
    }

    // 判断一个整数值是否对应一个有效的状态
    public static boolean isValidStatus(int status) {
        for (OrderStatusEnum orderStatus : OrderStatusEnum.values()) {
            if (orderStatus.getValue() == status) {
                return true;
            }
        }
        return false;
    }

    // 判断是否是有效的枚举值（枚举对象）
    public static boolean isValidEnum(OrderStatusEnum orderStatus) {
        return orderStatus != null;  // 这里判断是否为null
    }
}
